home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / c / objam01.lha / objam / objc / objc-api.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-02-10  |  3.6 KB  |  128 lines

  1. /*
  2. ** ObjectiveAmiga: GNU Objective-C Runtime API
  3. ** See GNU:lib/libobjam/ReadMe for details
  4. */
  5.  
  6.  
  7. #ifndef __objc_api_INCLUDE_GNU
  8. #define __objc_api_INCLUDE_GNU
  9.  
  10. #include <objc/objc.h>
  11. #include "hash.h"
  12. #include <stdio.h>
  13.  
  14.  
  15. /*
  16. ** Set this variable nonzero to print a line describing each
  17. ** message that is sent.  (this is currently disabled)
  18. */
  19. extern BOOL objc_trace;
  20.  
  21.  
  22. /*
  23. ** This is a hook which is called by objc_lookup_class and
  24. ** objc_get_class if the runtime is not able to find the class.
  25. ** This may e.g. try to load in the class using dynamic loading.
  26. ** The function is guaranteed to be passed a non-NULL name string.
  27. */
  28. extern OCClass* (*_objc_lookup_class)(const char *name);
  29.  
  30. Method_t class_get_class_method(MetaClass* class, SEL aSel);
  31.  
  32. Method_t class_get_instance_method(OCClass* class, SEL aSel);
  33.  
  34. OCClass* class_pose_as(OCClass* impostor, OCClass* superclass);
  35.  
  36. OCClass* objc_get_class(const char *name);
  37.  
  38. OCClass* objc_lookup_class(const char *name);
  39.  
  40. const char *sel_get_name(SEL selector);
  41.  
  42. SEL sel_get_uid(const char *name);
  43.  
  44. SEL sel_register_name(const char *name);
  45.  
  46. BOOL sel_is_mapped (SEL aSel);
  47.  
  48. static inline const char *class_get_class_name(OCClass* class)
  49. { return CLS_ISCLASS(class)?class->name:((class==Nil)?"Nil":0); }
  50.  
  51. static inline long class_get_instance_size(OCClass* class)
  52. { return CLS_ISCLASS(class)?class->instance_size:0; }
  53.  
  54. static inline MetaClass *class_get_meta_class(OCClass* class)
  55. { return CLS_ISCLASS(class)?class->class_pointer:Nil; }
  56.  
  57. static inline OCClass* class_get_super_class(OCClass* class)
  58. { return CLS_ISCLASS(class)?class->super_class:Nil; }
  59.  
  60. static inline int class_get_version(OCClass* class)
  61. { return CLS_ISCLASS(class)?class->version:-1; }
  62.  
  63. static inline BOOL class_is_class(OCClass* class)
  64. { return CLS_ISCLASS(class); }
  65.  
  66. static inline BOOL class_is_meta_class(OCClass* class)
  67. { return CLS_ISMETA(class); }
  68.  
  69. static inline void class_set_version(OCClass* class, long version)
  70. { if(CLS_ISCLASS(class)) class->version = version; }
  71.  
  72. static inline IMP method_get_imp(Method_t method)
  73. { return (method!=METHOD_NULL)?method->method_imp:(IMP)0; }
  74.  
  75. IMP get_imp (OCClass* class, SEL sel);
  76.  
  77.  
  78. static inline OCClass *object_get_class(id object)
  79. {
  80.   return ((object!=nil)
  81.       ? (CLS_ISCLASS(object->class_pointer)
  82.          ? object->class_pointer
  83.          : (CLS_ISMETA(object->class_pointer)
  84.         ? (OCClass*)object
  85.         : Nil))
  86.       : Nil);
  87. }
  88.  
  89. static inline const char *object_get_class_name(id object)
  90. {
  91.   return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
  92.                          ?object->class_pointer->name
  93.                          :((OCClass*)object)->name)
  94.       :"Nil");
  95. }
  96.  
  97. static inline MetaClass *object_get_meta_class(id object)
  98. {
  99.   return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
  100.                          ?object->class_pointer->class_pointer
  101.                          :(CLS_ISMETA(object->class_pointer)
  102.                            ?object->class_pointer
  103.                            :Nil))
  104.       :Nil);
  105. }
  106.  
  107. static inline OCClass *object_get_super_class(id object)
  108. {
  109.   return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
  110.                          ?object->class_pointer->super_class
  111.                          :(CLS_ISMETA(object->class_pointer)
  112.                            ?((OCClass*)object)->super_class
  113.                            :Nil))
  114.       :Nil);
  115. }
  116.  
  117. static inline BOOL object_is_class(id object)
  118. { return CLS_ISCLASS((OCClass*)object); }
  119.  
  120. static inline BOOL object_is_instance(id object)
  121. { return (object!=nil)&&CLS_ISCLASS(object->class_pointer); }
  122.  
  123. static inline BOOL object_is_meta_class(id object)
  124. { return CLS_ISMETA((OCClass*)object); }
  125.  
  126.  
  127. #endif /* not __objc_api_INCLUDE_GNU */
  128.